<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class CI_LastFmAPI {

	var $CI;
	var $config;
	var $lastfmapi;
	var $auth;
	var $apiClass;
	
	const LASTFMAPI_BASE_FILE = 'lastfmapi.php';
	
    function CI_LastFmAPI()
    {
		$ci_instance =& get_instance();
		$ci_instance->config->load( 'lastfmapi' );
		$dir_path = $ci_instance->config->item( 'lastfmapi_dir' );
		require_once( sprintf ( "%s/%s", $dir_path, self::LASTFMAPI_BASE_FILE ) );
		
		
		$this->apiClass = new lastfmApi();
		
		$config = $ci_instance->config->item( 'lastfmapi' );
		$this->config = $config;
			
		$auth = new lastfmApiAuth('setsession', $this->config);
		
		$this->auth = $auth;
    }

    function getAuth()
    {
		$auth = new lastfmApiAuth('setsession', $this->config);
		$this->auth = $auth;
		return $auth;
    }
    
    function getPackage($auth=NULL,$packageName=NULL) {
    	# for using standard getPackage
    	if (is_object($auth))
    	{
    		return $this->apiClass->getPackage($auth,$packageName);
    	}
    	else # if you want to use getPackage w/out auth (use CI object's auth)
    	{

    		return $this->apiClass->getPackage($this->auth,$auth);
    	}
    }
}

?>